//
// Created by ziya on 2024/1/6.
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>

#include "../include/ioctl_req.h"

char arr1[0x1000];
char arr2[0x1000] = {1};

char* s = "ziya";

int main(int argc, char* argv[]) {
    int a = 10;

    void* p1 = mmap(NULL, 1, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    void* p2 = malloc(1);

    printf("arr1 addr:  0x%lx\n", arr1);
    printf("arr2 addr:  0x%lx\n", arr2);
    printf("s addr:     0x%lx\n", s);

    printf("main addr:  0x%lx\n", main);
    printf("argc addr:  0x%lx\n", &argc);
    printf("argv addr:  0x%lx\n", &argv);
    printf("a addr:     0x%lx\n", &a);

    printf("p1 addr:    0x%lx\n", p1);
    printf("p2 addr:    0x%lx\n", p2);

    {
        int fd = open(R3_DEVICE_NAME, O_RDWR);
        if (fd < 0) {
            perror("open fail");
        }

        ulong pid = getpid();
        ioctl(fd, IOCTL_ZY_GET_PROCESS_MM_RESULT2, &pid);

        close(fd);
    }

    return 0;
}
